home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '88 / Proceedings '88 / Feldt Advanced Mac Programming / SCSI Manager / ssgSCSI.h < prev   
Encoding:
C/C++ Source or Header  |  1988-06-16  |  4.3 KB  |  139 lines  |  [TEXT/KAHL]

  1. /* 
  2.         Copyright (c) 1987 by small systems guild
  3.         
  4.         small systems guild
  5.         PO box 2751
  6.         Ann Arbor, MI 48106
  7.         (313) 996-4238
  8.         
  9.         File:         ssgSCSI.h
  10.         Model:         LightSpeed C 2.13, Aztec C 3.0
  11.         Target:     Macintosh Operating System
  12.         
  13. */
  14.  
  15. #define        MAX_BLOCKS        32
  16. #define        SIZE            MAX_BLOCKS * 512
  17. #define        TIME_OUT        3600
  18. #define        maxDrvs            8
  19. #define        P_DOUT            0x00        /* 0x60    data out */
  20. #define        P_DIN            0x01        /* 0x64 data in */
  21. #define        P_CMD            0x02        /* 0x68 command */
  22. #define        P_STAT            0x03        /* 0x6C status */
  23. #define        P_MOUT            0x06        /* 0x70 Message Out */
  24. #define        P_MIN            0x07        /* 0x74 Message In */
  25.  
  26. /*  transfer instruction op codes  */
  27. enum {
  28.     scInc = 1,
  29.     scNoInc,
  30.     scAdd,
  31.     scMove,
  32.     scLoop,
  33.     scNop,
  34.     scStop,
  35.     scComp
  36. };
  37.  
  38. /*  result codes  */
  39. enum {
  40.     scCommErr = 2,
  41.     scBadParmsErr = 4,
  42.     scPhaseErr,
  43.     scCompareErr
  44. };
  45.  
  46. typedef struct SCSIInstr {
  47.     int                    scOpcode;
  48.     unsigned long        scParam1;
  49.     unsigned long        scParam2;
  50. } SCSIInstr;
  51.  
  52. struct scsicmd {
  53.     char    sc_cmd;            /* command code */
  54.     char    sc_adrH;        /* High Byte of address */
  55.     char    sc_adrM;        /* Middle byte of address */
  56.     char    sc_adrL;        /* Low byte of address */
  57.     char    sc_arg;            /* count or interleave value */
  58.     char    sc_vendor;        /* vendor byte -- seek algorithm */
  59. };
  60.  
  61. struct scsisense {
  62.     char    ss_code;        /* status code */
  63.     char    ss_adrH;        /* address when valid */
  64.     char    ss_adrM;
  65.     char    ss_adrL;
  66. };
  67.  
  68. struct Volume {
  69.         short    drSigWord;        /* should be $D2D7 */
  70.         long    drCrDate;        /* date and time of initialization */
  71.         long    drLsBkUp;        /* date and time of last backup */
  72.         short    drAtrb;            /* volume attributes */
  73.         short    drNumFls;        /* # of files in file directory */
  74.         short    drDirSt;        /* first logical block of file dir */
  75.         short    drBlLen;        /* # of logical blocks in file dir */
  76.         short    drNmAlBlks;        /* # of allocation blocks on volume */
  77.         long    drAlBlkSiz;        /* size of allocation blocks */
  78.         long    drClpSiz;        /* # of bytes to allocate */
  79.         short    drAlBlSt;        /* logical block number of first
  80.                                    allocation block */
  81.         long    drNxtFNum;        /* next unused file number */
  82.         short    drFreeBks;        /* # of unused allocation blocks */
  83.         char    drVN;            /* length of volume name */
  84.         char    drFill[512-37];    /* volume name & start of alloc. map */
  85. };
  86.  
  87. /*
  88.  * NCR5380 registers on the MacSCSI host adapter found at
  89.  * location 0x500000
  90.  */
  91.  
  92. struct NCR5380 {
  93.     char wr_data,    filla;        /* force scsi bus data */
  94.     char wr_icmd,    fillb;        /* initiator command */
  95.     char wr_mode,    fillc;        /* ncr5380 mode */
  96.     char wr_tcmd,    filld;        /* target command */
  97.     char wr_sele,    fille;        /* select enable */
  98.     char wr_send,    fillf;        /* start send operation */
  99.     char wr_trec,    fillg;        /* start target recieve */
  100.     char wr_irec,    fillh;        /* start initiator recieve */
  101.     char fill00,    rd_data;    /* current scsi bus data */
  102.     char fill01,    rd_icmd;    /* initiator command status */
  103.     char fill02,    rd_mode;    /* ncr 5380 mode */
  104.     char fill03,    rd_tcmd;    /* target command status */
  105.     char fill04,    rd_bstat;    /* current bus status */
  106.     char fill05,    rd_stat;    /* chip bus and status info */
  107.     char fill06,    rd_input;    /* input data */
  108.     char fill07,    rd_reset;    /* reset strobe */
  109. };
  110.  
  111. typedef struct NCR5380 NCR5380;OSErr     gSC_unitReady(int);                /* test unit ready device status            */
  112. OSErr     gSC_reqSense(int);                /* request sense error and status info        */
  113. OSErr     gSC_select(int);                /* arbitrates bus and selects SCSI device    */
  114. OSErr     gSC_loadUnload(int);            /* load/unload and synchronize the device    */
  115. OSErr     gSC_inquire(int);                /* inquire device ID and attributes            */
  116. OSErr     gSC_rdCapacity(int,Byte *buf);    /* get device capacity as hi block & size    */
  117. OSErr     gSC_read(int,Byte *,Int32,Int16,UInt16);  /* read data from the SCSI device    */
  118.  
  119. OSErr     gSC_write(int,Byte *,Int32,Int16,UInt16); /* write data to the SCSI device    */
  120.  
  121. OSErr     gSC_error(OSErr);                /* prints error messages if verbose TRUE    */
  122. OSErr     gSC_cmd(Byte *);                /* handles 6 byte SCSI commands only        */
  123. OSErr     gSC_6cmd(Byte *);                /* issue 6 byte SCSI command, no completion    */
  124. OSErr     gSC_10cmd(Byte *);                /* issue 10 byte SCSI command, no completion*/
  125. Byte *    gSC_TIB(Byte *,long,long);        /* create transfer instruction block code    */
  126. OSErr    gSC_CMD(Byte,long,long);    /* create SCSI command block structure        */
  127.                 
  128. extern struct SCSIInstr cmdbuf;
  129. extern struct SCSIInstr mbuf[3];
  130. extern Byte                dat[SIZE];
  131. extern Byte                tst[10];
  132. extern Byte                hdr[1024];
  133.  
  134. extern int                sect,stat,msg;
  135. extern Byte                *cmp;
  136. extern long                wait,len;
  137. extern OSErr            err;
  138. extern int                verbose;
  139.